/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* intersection(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize)
{
    int* arr = (int*)malloc(sizeof(int) * 1010);
    bool check[1500] = { 0 };
    bool che[1500] = { 0 };
    for (int i = 0; i < nums1Size; i++)
        check[nums1[i]] = true;
    int cal = 0;
    for (int i = 0; i < nums2Size; i++)
        if (check[nums2[i]] && che[nums2[i]] == false)
        {
            che[nums2[i]] = true;
            arr[cal++] = nums2[i];
        }

    *returnSize = cal;
    return arr;
}